package com.software.loginregister.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.software.loginregister.fragment.AiFragment;
import com.software.loginregister.fragment.CommunityFragment;
import com.software.loginregister.fragment.HomeFragment;
import com.software.loginregister.fragment.MineFragment;

import java.util.Arrays;
import java.util.List;

public class ViewPagerAdapter extends FragmentStateAdapter {
    private final List<Fragment> fragments;

    public ViewPagerAdapter(FragmentActivity activity) {
        super(activity);
        fragments = Arrays.asList(
                new HomeFragment(),
                new AiFragment(),
                new CommunityFragment(),
                new MineFragment()
        );
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return fragments.get(position);
    }

    @Override
    public int getItemCount() {
        return fragments.size();
    }
}